package edu.pku.sei.transformation.editor.controller.commands.link;

import edu.pku.sei.transformation.editor.model.requirement.GoalRelationship;
import edu.pku.sei.transformation.editor.model.requirement.TransformationGoal;

public class GoalRelationshipDeleteCommand extends
		AbstractLinkDeleteCommand<GoalRelationship, TransformationGoal, TransformationGoal> {

	public GoalRelationshipDeleteCommand(GoalRelationship link,
			TransformationGoal source, TransformationGoal target) {
		super(link, source, target);
		if (link.getType() == GoalRelationship.TYPE_INCLUDE) 
			setLabel("delete include");
		else
			setLabel("delete dependent");
	}
	
	@Override
	public void undo() {
		source.getRelationships().add(link);
		link.setSourceGoal(source);
		link.setTargetGoal(target);
	}
	
	@Override
	public void execute() {
		source.getRelationships().remove(link);
		link.setSourceGoal(null);
		link.setTargetGoal(null);
	}

}
